package kin.serviceIMP.security;

import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import kin.bean.security.Acl;
import kin.bean.security.AclId;
import kin.bean.security.Module;
import kin.manager.security.AclManager;
import kin.service.security.AclServiceManager;

@Service
public class AclServiceManagerIMP implements AclServiceManager {
	@Inject
private AclManager aclManager;
	public List<Acl> findAll() {
		// TODO Auto-generated method stub
		return this.aclManager.findAll();
	}

	public void addOrUpdatePermission(String principalType, int principalId,
			int moduleId, int permission, boolean yes) {
		this.aclManager.addOrUpdatePermission(principalType, principalId, moduleId, permission, yes);

	}

	public void delPermission(String principalType, int principalId,
			int moduleId) {
		this.aclManager.delPermission(principalType, principalId, moduleId);

	}

	public void addOrUpdateUserExtends(int userId, int moduleId, boolean yes) {
		this.aclManager.addOrUpdateUserExtends(userId, moduleId, yes);

	}

	public boolean hasPermission(int userId, int moduleId, int permission) {
		// TODO Auto-generated method stub
		return this.hasPermission(userId, moduleId, permission);
	}

	public List<Module> findModulesByUser(int userId) {
		// TODO Auto-generated method stub
		return this.aclManager.findModulesByUser(userId);
	}

	public List findPermissionsByRole(int userId) {
		// TODO Auto-generated method stub
		return this.aclManager.findPermissionsByRole(userId);
	}

	public void delPermissionsByRole(int userId) {
		this.aclManager.delPermissionsByRole(userId);

	}

	public AclId findAclId(String principalType, int principalId, int moduleId) {
		// TODO Auto-generated method stub
		return this.aclManager.findAclId(principalType, principalId, moduleId);
	}

	public AclManager getAclManager() {
		return aclManager;
	}

	public void setAclManager(AclManager aclManager) {
		this.aclManager = aclManager;
	}

	@Override
	public void delPermissionsByModule(int moduleId, int permission) {
		this.aclManager.delPermissionsByModule(moduleId, permission);
		
	}

	@Override
	public void delAclByModule(int moduleId) {
		this.aclManager.delAclByModule(moduleId);
		
	}

	@Override
	public List<Acl> findByUser(String principalType, int userId) {
		// TODO Auto-generated method stub
		return this.aclManager.findByUser(principalType, userId);
	}
	
	

}
